package com.noble.glamour.ui.user.paygoods;

import android.widget.RelativeLayout;
import android.widget.TextView;

import com.noble.meether.R;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewAdapter;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewHolder;
import com.noble.meether.ui.diamond.bean.Diamond;

/**
 * 通用商品列表adapter
 * Created by Su on 2017/3/31.
 */

public class GoodsListAdapter extends BaseRecyclerViewAdapter {
    private int selectPosition = 0;

    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.f1_goods_item_new};
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, final int position) {
        final Diamond data = (Diamond) getItem(position);

        RelativeLayout payItem = viewHolder.findViewById(R.id.pay_item);
        TextView tv_name = viewHolder.findViewById(R.id.tv_name);       // 商品名称
        TextView tv_money = viewHolder.findViewById(R.id.tv_money);     // 商品价格

        // 选中状态
        payItem.setSelected(selectPosition == position);

        // 设置数据
        tv_name.setText(String.valueOf(data.getDoPay()));

        //Html.fromHtml("&#165;").toString() + data.getPrice()
        tv_money.setText(data.getAmount() + "元");
    }

    public void updateData(int positon) {
        this.selectPosition = positon;
        notifyDataSetChanged();
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }
}
